package com.reremouse.rerebbs.dao.impl;

import com.reremouse.model.AdminInfo;
import com.reremouse.rerebbs.dao.IAdminDAO;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.io.Serializable;
import java.util.List;

public class AdminDAO
        implements IAdminDAO, Serializable {
    @PersistenceContext
    private EntityManager entityManager;

    public EntityManager getEntityManager() {
        return this.entityManager;
    }

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    public void addAdmin(AdminInfo paramAdminInfo) {
        this.entityManager.persist(paramAdminInfo);
    }

    public void deleteAdmin(long paramString) {
        AdminInfo ai = (AdminInfo) this.entityManager.find(AdminInfo.class, Long.valueOf(paramString));
        this.entityManager.remove(ai);
    }

    public AdminInfo findAdmin(long paramString) {
        AdminInfo ai = (AdminInfo) this.entityManager.find(AdminInfo.class, Long.valueOf(paramString));
        return ai;
    }

    public AdminInfo findAdminByUrn(String paramString) {
        String q = "Select ais from AdminInfo ais where ais.urn='" + paramString + "'";
        List<AdminInfo> as = this.entityManager.createQuery(q).getResultList();
        if (as.isEmpty()) {
            return null;
        }
        AdminInfo ai = (AdminInfo) as.get(0);
        return ai;
    }

    public List<AdminInfo> findAllAdmin() {
        String q = "Select ais from AdminInfo ais";
        List<AdminInfo> ais = this.entityManager.createQuery(q).getResultList();
        return ais;
    }

    public void updateAdmin(AdminInfo paramAdminInfo) {
        this.entityManager.merge(paramAdminInfo);
    }
}



/* Location:           F:\jsp源码\蝙蝠论坛系统\rerebbs\WEB-INF\classes\

 * Qualified Name:     com.reremouse.rerebbs.dao.impl.AdminDAO

 * JD-Core Version:    0.7.0.1

 */